#ifndef _2D_RENDERER_H_
#define _2D_RENDERER_H_

#include "kernelTask.h"
#include "XMLSettings.h"
#include "GCPtr.h"
#include <SDL.h>
#include <SDL_image.h>
#include <vector>
#include "Unit.h"

class Renderer2d : public IKernelTask
{
	public:
		~Renderer2d();

		static GCPtr<Renderer2d> getInstance();

		bool Start();
		void Stop();
		void Update();

		void addRenderable(CUnit* unit);
		void removeRenderable(CUnit* unit);

	private:
		Renderer2d( void );
		Renderer2d( Renderer2d const& );
		Renderer2d& operator=( Renderer2d const& );

		// Intits stuff
		bool init();

		// Draws the whole image you send in at x,y
		bool draw( SDL_Surface* surf_dest, SDL_Surface* surf_src, int x, int y );

		// Draws a part of your image specified by the rect
		bool draw( SDL_Rect* src_rect, SDL_Surface* surf_dest, SDL_Surface* surf_src, int x, int y );

		// Keys away a color from the image (black)
		void colorKeying( SDL_Surface* surface );

		// Surfaces
		SDL_Surface* surf_screen;

		// Screen w & h
		int width;
		int height;

		// Bit depth
		int bitDepth;

		vector<CUnit*> vRenderables;
};

#endif